/**
 * Created by 魏爷 on 2016/5/31.
 */
$(function(){
    var url=$('#tradeStatus').val();
    var ss_url=$('#ss-url').val();
    var app={
        save:function(obj){
            var loading=layer.load(1);
            $.post(
                url,
                {buybook_id:obj.attr('data-id')},
                function(res){
                    layer.close(loading);
                    if(res.status==1){
                        layer.msg(res.info,{icon:1});
                        window.location.reload();
                    }else{
                        layer.msg(res.info,{icon:2});
                        window.location.reload();
                    }
                });
        },

        ss:function(obj){
            var loading=layer.load(1);
            $.post(
                ss_url,
                {buybook_id:obj.attr('data-id-status')},
                function(res){
                    layer.close(loading);
                    if(res.status==1){
                        layer.msg(res.info,{icon:1});
                        window.location.reload();
                    }else{
                        layer.msg(res.info,{icon:2});
                        window.location.reload();
                    }
                });
        },
    }
    $('.save').click(function () {
        app.save($(this));
    });
    $('.ss').click(function () {
        app.ss($(this));
    });
});